<template>
  <div class="categories-container">
    <h2>Movie Categories</h2>

    <div class="category-list">
      <div
        v-for="genre in genres"
        :key="genre"
        class="category-item"
        @click="viewGenreMovies(genre)"
      >
        {{ genre }}
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import { useRouter } from 'vue-router';

const genres = ref([
  'Action',
  'Adventure',
  'Comedy',
  'Drama',
  'Fantasy',
  'Horror',
  'Sci-Fi',
  'Thriller'
]);

const router = useRouter();

const viewGenreMovies = (genre) => {
  router.push({ path: `/genre/${genre}` });
};
</script>

<style scoped>
.categories-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.category-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 15px;
  margin-top: 30px;
}

.category-item {
  background-color: white;
  border-radius: 8px;
  padding: 15px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: all 0.3s;
}

.category-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  background-color: #f0f0f0;
}
</style>